package cn.com.infcn.spider.domain;

import com.mongodb.DBObject;

import cn.com.infcn.spider.util.ObjConver;

/**
 * 网址队列信息
 * 
 * @author ansj
 *
 */
public class UrlInfo extends UriInfo {

	private int depth = 0; // 深度

	private String fromUrl; // 来源网址

	public UrlInfo() {
	}

	public UrlInfo(DBObject obj) {
		super(obj);
		this.depth = ObjConver.castToInt(obj.get("errCount"));
		this.fromUrl = (String) obj.get("fromUrl");
	}

	public UrlInfo(String url) {
		this.uri = url;
	}

	public UrlInfo(UrlInfo from, String url) {
		this.uri = url;
		this.depth = from.depth + 1;
		this.fromUrl = from.uri;
	}

	public int getDepth() {
		return depth;
	}

	public void setDepth(int depth) {
		this.depth = depth;
	}

	public String getFromUrl() {
		return fromUrl;
	}

	public void setFromUrl(String fromUrl) {
		this.fromUrl = fromUrl;
	}

	@Override
	public int hashCode() {
		return uri.hashCode();
	}

	@Override
	public boolean equals(Object obj) {
		return uri.equals(obj);
	}

	
}
